package com.by.controller;

import com.by.domian.AjaxResult;
import com.by.entity.Order;
import com.by.service.OrderService;
import com.by.utils.Assert;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "订单管理")
public class OrderController {

    @Autowired
    OrderService orderService;

    @PutMapping("/order")
    @ApiOperation("保存订单")
    public AjaxResult saveOrder(@RequestBody Order order){
            boolean save = orderService.save(order);
        return AjaxResult.success("保存成功",order);
    }

    @DeleteMapping("/order")
    @ApiOperation("根据id删除订单 ")
    public AjaxResult deleteOrder(int id){
        //删除之前查看是否存在此订单
        boolean b = orderService.removeById(id);
        return AjaxResult.success("删除订单成功");
    }
}
